/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package task02bt02;

import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author tanhung
 */
public class Bai02 {
    public void run() throws IOException
    {
        
        FileInputStream fis = null;
        String sDuongDan;
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        
        try {
            String line;
            int soLuongPhanTu;
            
            System.out.println("Nhap duong dan tap tin du lieu:");
            sDuongDan = bf.readLine();
            fis = new FileInputStream(sDuongDan);
            BufferedReader fbf = new BufferedReader(new InputStreamReader(fis));
            
            line = fbf.readLine(); // doc dong dau tien
            soLuongPhanTu = Integer.parseInt(line);
            
            PhanSo[] mangPhanSo = new PhanSo[soLuongPhanTu];
            //Lay danh sach cac phan so
            for(int i = 0; i < soLuongPhanTu; i++)
            {
                mangPhanSo[i] = new PhanSo();
                line = fbf.readLine();
                String[] sPart = line.split("/");
                mangPhanSo[i].tuSo = Integer.parseInt(sPart[0]);
                mangPhanSo[i].mauSo = Integer.parseInt(sPart[1]);
            }
            
            //Xuat ra danh sach cac phan so
            for(int i = 0; i < soLuongPhanTu; i++)
            {
                mangPhanSo[i].Xuat();
                System.out.println("");
            }
            
        } catch (IOException ex) {
            Logger.getLogger(Bai02.class.getName()).log(Level.SEVERE, null, ex);
        }finally{
            if(fis != null)
            {
                fis.close();
            }
        }
    }
}
